home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 961 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. Path: news.ahc.ameritech.com!datalytics!news
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Faster FILE subroutines in standard C?
  5. Date: 8 Jan 1996 17:45:32 GMT
  6. Organization: Datalytics, Inc
  7. Message-ID: <4crl7s$h4r@gold.datalytics.com>
  8. References: <4cflbt$d4h@sunburst.ccs.yorku.ca> <4cges0$kqi@news1.usa.pipeline.com>
  9. NNTP-Posting-Host: pc071.datalytics.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15. grantp@usa.pipeline.com(Pete) wrote:
  16. >On Jan 04, 1996 04:34:05 in article <Re: Faster FILE subroutines in
  17. >standard C?>, 'ken@yorku.ca (Kenneth Kafieh)' wrote: 
  18. >>Ken (ken@afep.yorku.ca) wrote: 
  19. >> 
  20. >>: I found that I was able to get 3-4 time faster performance by using good
  21. >>: old ANSI C file accessing routines (like  fgets, fseek, ftell, ...etc.) 
  22. >>: instead of C++ streams (like ifstream::getline, fstream::seekg, ...etc.)
  23. >
  24.  
  25. [snip]
  26.  
  27. >>: Does that sound right?   
  28. >No. 
  29. >>:                         Maybe my code was inefficiently written? 
  30. >That would be my guess -- given the difference. 
  31.  
  32. Writing good code for the iostreams library is difficult; the 
  33. iostreams code may have been inefficient.
  34.  
  35. >>: I know C++ is generally slower than C but I didn't think that  
  36. >Why do you say that?  
  37.  
  38. C++ is not slower than C on the same code.  It's that C++ 
  39. makes it easier to do things than they were in C, so we tend 
  40. to do fancier things (behind the scenes, anyway).  So long as 
  41. you don't take advantage of any of the features of C++ that 
  42. would make your code slower, you wouldn't see any difference.  
  43. (Don't forget that every C++ compiler also compiles C code.)
  44.  
  45. As soon as you make use of virtual base classes, polymorphism, 
  46. etc., your code runs slower.  The advantage is type safety, 
  47. flexibility, and ease of expression.  There are always 
  48. tradeoffs to be made.
  49.  
  50. [snip]
  51.  
  52. >> 
  53. >I wouldn't place too much value in the results of an old  
  54. >implementation of a library.  BC20 was released about five years 
  55. >ago so its performace is really not applicable today.  
  56. >I haven't performed actual tests; however, with today's compiler 
  57. >systems there is a negligible apparent difference (if any) 
  58. >between stdio and iostreams -- at least in the applications 
  59. >I've converted from one to the other. 
  60.  
  61. The iostreams library is slower than the stdio stuff, though 
  62. perhaps not by a large margin anymore.  That's not the point.  
  63. The point of iostreams was a demonstration of multiple 
  64. inheritance.  As a benefit, it provided a simplified, typesafe 
  65. form of file I/O.
  66.  
  67. -- 
  68. Robert Stewart        | My opinions are usually my own.
  69. Datalytics, Inc.
  70. (513)226-7700
  71. stew@datalytics.com
  72.  
  73.  
  74.